package com.tianaceae.educational.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.tianaceae.educational.domain.EduRoom;
import com.tianaceae.educational.service.IEduRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 教务_教室Controller
 * 
 * @author zhouhonggang
 * @date 2023-03-25
 */
@RestController
@RequestMapping("/educational/room")
public class EduRoomController extends BaseController
{
    @Autowired
    private IEduRoomService eduRoomService;

    /**
     * 查询教务_教室列表
     */
    @PreAuthorize("@ss.hasPermi('educational:room:list')")
    @GetMapping("/list")
    public TableDataInfo list(EduRoom eduRoom)
    {
        startPage();
        List<EduRoom> list = eduRoomService.selectEduRoomList(eduRoom);
        return getDataTable(list);
    }

    /**
     * 导出教务_教室列表
     */
    @PreAuthorize("@ss.hasPermi('educational:room:export')")
    @Log(title = "教务_教室", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EduRoom eduRoom)
    {
        List<EduRoom> list = eduRoomService.selectEduRoomList(eduRoom);
        ExcelUtil<EduRoom> util = new ExcelUtil<EduRoom>(EduRoom.class);
        util.exportExcel(response, list, "教务_教室数据");
    }

    /**
     * 获取教务_教室详细信息
     */
    @PreAuthorize("@ss.hasPermi('educational:room:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eduRoomService.selectEduRoomById(id));
    }

    /**
     * 新增教务_教室
     */
    @PreAuthorize("@ss.hasPermi('educational:room:add')")
    @Log(title = "教务_教室", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EduRoom eduRoom)
    {
        return toAjax(eduRoomService.insertEduRoom(eduRoom));
    }

    /**
     * 修改教务_教室
     */
    @PreAuthorize("@ss.hasPermi('educational:room:edit')")
    @Log(title = "教务_教室", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EduRoom eduRoom)
    {
        return toAjax(eduRoomService.updateEduRoom(eduRoom));
    }

    /**
     * 删除教务_教室
     */
    @PreAuthorize("@ss.hasPermi('educational:room:remove')")
    @Log(title = "教务_教室", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eduRoomService.deleteEduRoomByIds(ids));
    }
}
